using System;
using UnityEngine;

namespace Prototype.JumpOverTheWorld
{
    public class SpawnManager : MonoBehaviour
    {
        public GameObject obstaclePrefab;
        public float SpawnInterval = 2f;
        public Vector3 SpawnPos = new Vector3(0,0,0);
        private float nextSpawnTime = 0;
        private float startDelay = 2;
        private PlayerController playerControllerScript;



        private void Start()
        {
             playerControllerScript = FindObjectOfType<PlayerController>();
            InvokeRepeating("SpawnObstacle",startDelay,SpawnInterval);
        }

        void SpawnObstacle()
        {
            if(playerControllerScript.gameOver == false)
            {
                Instantiate(obstaclePrefab,SpawnPos,obstaclePrefab.transform.rotation);
            }
            
        }
        
    }
}